define(['app'], function(app) {
	'use strict';
	//实例化方法
	var factory = function(Http) {
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		//新品测试
		function get_data_gettestlist(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"act": [{"act_id": "001","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/01/31 09:00:00","goods": {"id": "001","name": "一字螺丝刀","image": "./img/upload/pro-img01.jpg","price": 200.00,"store_id":"001","store_name":"五金公司1"}}, {"act_id": "002","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/01/31 09:00:00","goods": {"id": "002","name": "十字螺丝刀","image": "./img/upload/pro-img01.jpg","price": 200.00,"store_id":"002","store_name":"五金公司2"}}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_getgivinglist(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"act": [{"act_id": "001","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/01/31 09:00:00","goods": {"id": "001","name": "一字螺丝刀","image": "./img/upload/pro-img01.jpg","price":"300","store_id":"003","store_name":"五金公司3"}},{"act_id": "002","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/01/31 09:00:00","goods": {"id": "002","name": "十字螺丝刀","image": "./img/upload/pro-img01.jpg","price":"300","store_id":"004","store_name":"五金公司4"}}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_getadvideolist(result) {
			if(false) {
				result = '{"success":true,"msg":"","result":{"act":[{"act_id":"001","name":"促销","start_time":"2017/01/01 09:00:00","end_time":"2017/01/31 09:00:00","goods":[{"id":"001","name":"一字螺丝刀","image":"001.jpg","price":"111.00","store_id":"001","store_name":"未来万家","video":"001.mp4"},{"id":"002","name":"十字螺丝刀","image":"002.jpg","price":"111.00","store_id":"001","store_name":"未来万家","video":"002.mp4"}]},{"act_id":"002","name":"促销","start_time":"2017/01/01 09:00:00","end_time":"2017/01/31 09:00:00","goods":[{"id":"003","name":"一字螺丝刀","image":"001.jpg","price":"111.00","store_id":"001","store_name":"未来万家","video":"003.mp4"},{"id":"004","name":"十字螺丝刀","image":"002.jpg","price":"111.00","store_id":"001","store_name":"未来万家","video":"004.mp4"}]}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		
		//返回信息
		return {
			//新品测试
			get_test_list: function(nPage, act_type,callback,calldone) {
				Http.post({
					method: 'goods.test.getlist',
					nPage:nPage,
					act_type:act_type,
					pagelimit:10
				}, function(result) {
					//请求成功
					if(callback) {
						callback(get_data_gettestlist(result).result,get_data_gettestlist(result).process_time);
					}
				}, function(e) {
					//请求异常
				}, function() {
					//请求完成，一般不做什么事情
					if(calldone)
						calldone();
				});
			},
			//新品赠送
			get_giving_list: function(nPage, act_type,callback,calldone) {
				Http.post({
					method: 'marketing.giving.goodslist',
					pagelimit:10,
					nPage: nPage,
					act_type:act_type
				}, function(result) {
					//请求成功
					if(callback) {
						callback(get_data_getgivinglist(result).result,result.process_time);
					}
				}, function(e) {
					//请求异常
				}, function() {
					//请求完成，一般不做什么事情
					if(calldone)
						calldone();
				});
			},
			//新品公告
			get_notice_list: function(nPage, act_type, callback,calldone) {
				Http.post({
					method: 'marketing.notice.getlist',
					pagelimit: 10,
					nPage:nPage,
					act_type:act_type
				}, function(result) {
					//请求成功
					if(callback) {
						callback(get_data_getadvideolist(result).result,result.process_time);
					}
				}, function(e) {
					//请求异常
				}, function() {
					//请求完成，一般不做什么事情
					if(calldone)
						calldone();
				});
			}
			
			
		};
	}
	
	
	factory.$inject = ['Http'];
	return app.registerService("Newpropromotions", factory);
});